package com.wzcl.app.controller;

import com.wzcl.app.dao.model.WorkShow;
import com.wzcl.app.model.common.MyPage;
import com.wzcl.app.model.common.RVO;
import com.wzcl.app.model.dto.WorkShowDto;
import com.wzcl.app.service.WorkShowService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;

/**
 * @author beingven
 * @Description 作品秀模块
 * @createTime 2020年12月12日 17:08:00
 */
@RestController
@RequestMapping("/workShow")
@Api(value="作品秀controller",tags={"作品秀接口"})
public class WorkShowController {
    @Resource
    private WorkShowService workShowService;

    @ApiOperation("添加作品秀")
    @PostMapping("/create")
    public RVO createWorkShow(@RequestBody WorkShowDto workShowDto) {
        return RVO.success(workShowService.createWorkShow(workShowDto));
    }

    @ApiOperation("根据id查询作品秀")
    @GetMapping("/retrieve/{id}")
    public RVO retrieveWorkShowById(@PathVariable Integer id) {
        return RVO.success(workShowService.retrieveWorkShowById(id));
    }

    @ApiOperation("根据id删除作品秀")
    @DeleteMapping("/delete/{id}")
    public RVO deleteWorkShowById(@PathVariable Integer id) {
        workShowService.deleteWorkShowById(id);
        return RVO.success();
    }

    @ApiOperation("修改作品秀")
    @PutMapping("/update")
    public RVO updateWorkShowById(@RequestBody WorkShowDto workShowDto) {
        workShowService.updateWorkShowById(workShowDto);
        return RVO.success();
    }

    @ApiOperation("根据条件分页查询作品秀")
    @PostMapping("/page/retrieveByUser")
    public RVO<MyPage<WorkShow>> retrieveAllByUserIdByPage(@RequestBody WorkShowDto workShowDto) {
        return RVO.success(workShowService.retrieveAllByUserIdByPage(workShowDto));
    }

    @ApiOperation("根据年级分页查询作品秀")
    @PostMapping("/page/retrieveByGrade")
    public RVO<MyPage<WorkShow>> retrieveAllByUserIdAndGradeByPage(@RequestBody WorkShowDto workShowDto) {
        return RVO.success(workShowService.retrieveAllByUserIdAndGradeByPage(workShowDto));
    }

    @ApiOperation("点赞/取消")
    @PutMapping("/giveLike")
    public RVO giveLike(@RequestParam Integer id) {
        return workShowService.giveLike(id);
    }

    @ApiOperation("推送/取消优秀作品")
    @PutMapping("/isPush")
    public RVO isPush(@RequestParam Integer id) {
        return workShowService.isPush(id);
    }

    @ApiOperation("自定义作品秀虚拟赞数")
    @PutMapping("/update/likeNumber")
    public RVO updateLikeNumber(@RequestParam Integer id, @RequestParam Integer likeNumber) {
        return workShowService.updateLikeNumber(id, likeNumber);
    }

    @ApiOperation("分页展示优秀作品")
    @PostMapping("/page/excellent")
    public RVO<MyPage<WorkShow>> getPageByExcellent(@RequestBody WorkShowDto workShowDto) {
        return RVO.success(workShowService.getPageByExcellent(workShowDto));
    }

    @ApiOperation("根据条件查询当前教师的课程下的作品秀")
    @PostMapping("/retrieve/notComment")
    public RVO getPageByNotComment(@RequestBody WorkShowDto workShowDto) {
        return RVO.success(workShowService.getPageByNotComment(workShowDto));
    }

    @ApiOperation("获取用户作品秀数据统计主页")
    @GetMapping("/retrieve/workShow/data/{userId}")
    public RVO getWorkShowDataByUserId(@PathVariable Integer userId) {
        return RVO.success(workShowService.getWorkShowDataByUserId(userId));
    }

    @ApiOperation("审核作品秀")
    @PutMapping("/update/workShow/check")
    public RVO updateWorkShowByCheckStatus(@RequestParam Integer id, @RequestParam Integer checkStatus) {
        return workShowService.updateWorkShowByCheckStatus(id, checkStatus);
    }
}